#!/usr/bin/python3

a = 21
b = 10
c = 0
def f1():
    c = a + b
    print("1 - c 的值为：", c)

def f2():
    c = a - b
    print("2 - c 的值为：", c)

def f3():
    c = a * b
    print("3 - c 的值为：", c)

def f4():
    c = a / b
    print("4 - c 的值为：", c)

def f5():
    c = a % b
    print("5 - c 的值为：", c)

def f6():
    # 修改变量 a 、b 、c
    a = 2
    b = 3
    c = a ** b
    print("6 - c 的值为：", c)

def f7():
    a = 10
    b = 5
    c = a // b
    print("7 - c 的值为：", c)

def f8():
    if(n:=10) > 5:
        print(n)

import time
def f9():
    for i in range(101): # 添加进度条图形和百分比
        bar = '[' + '=' * (i // 2) + ' ' * (50 - i // 2) + ']'
        print(f"\r{bar} {i:3}%", end='', flush=True)
        time.sleep(0.05)
    print()

def f10():
    name = "world"
    print("hello %s" % name)

def f11():
    name = "world"
    test = f'hello {name}'
    print(test)

    print(f'{1 + 5}')

def f12():
    var1='1234567'
    print(var1.istitle())

def f13():
    list1 = ['Google', 'Taobao', 'Runoob', 'Baidu']
    tuple1 = tuple(list1)
    print(tuple1,type(tuple1))

def f14():
    # 方法 1: 使用 list() 函数 (推荐)
    original_tuple = (1, 2, 3, 4, 5)
    converted_list = list(original_tuple)
    print("使用 list() 函数转换:", converted_list , type(converted_list))

    nested_tuple = ((1, 2), (3, 4), (5, 6))
    nested_list = list(nested_tuple)
    print("嵌套元组转换为嵌套列表:", nested_list)

    # 注意: 内层的元组不会自动转换为列表
    # 如果需要完全转换为列表，可以使用嵌套列表推导式
    fully_converted = [[element for element in sub_tuple] for sub_tuple in nested_tuple]
    print("完全转换为列表:", fully_converted)

def f15():
    tuple1 = (1, 2, 3, 4, 5)
    dict1 = dict.fromkeys(tuple1)
    print(f'dict {str(dict1)}')
    print(f'{dict1.get(20),5}')
    tinydict = {'RUNOOB': {'url': 'www.runoob.com'}}
    print(tinydict.get('RUNOOB').get('url'))

def f16():
    x = {"apple", "banana", "cherry"}
    y = {"google", "microsoft", "apple"}
    z = x.difference(y)
    print(x)
    print( y)
    print(z)

    x.difference_update(y)
    print(x)
    print(y)

def f17():
    # !/usr/bin/python3
    age = int(input("请输入你家狗狗的年龄: "))
    print("")
    if age <= 0:
        print("你是在逗我吧!")
    elif age == 1:
        print("相当于 14 岁的人。")
    elif age == 2:
        print("相当于 22 岁的人。")
    elif age > 2:
        human = 22 + (age - 2) * 5
        print("对应人类年龄: ", human)
    ### 退出提示
    input("点击 enter 键退出")

def f18():
    try:
        color = int(input("请输入颜色: "))
        match color:
            case 1:
                print("你输入的是红色")
            case 2:
                print("你输入的是蓝色")
            case _:
                print("你输入的颜色是黑色")
    except ValueError:
        print("输入有误，请输入数字")

def f19():
    for char in 'PYTHON STRING':
        if char == ' ':
            break

        print(char, end='')

        if char == 'O':
            continue


def f20():
    for i in range(0,20,2):
        print(i, end=', ')

def f21():
    var1 = [i for i in range(30) if i%3==0]
    print(var1)

def f22():
    list1 = [1, 2, 3, 4, 5]
    it=iter(list1)
    print(next(it))

    for i in list1:
        print(i,end=' ')

    print()
    print( f'{"="*20}')

    for i in it:
        print(i,end=' ')

if __name__ == '__main__':
    f22()